/**   
* @Title: YwShouLiView.java 
* @Package com.zjdiepu.www.manage.api.zpp.view 
* 
* @author zhangpp
* @date 2017年5月31日 上午11:01:59 
* @version V1.0   
*/
package com.zjdiepu.www.manage.api.zpp.view;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.base.enums.type.ResultFlagType;
import com.zjdiepu.www.common.util.UUIDFactory;
import com.zjdiepu.www.commpent.ViewScopeControllerHelper;
import com.zjdiepu.www.dao.yw.YwTransferMapper;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessCarService;
import com.zjdiepu.www.model.yw.dto.YwBusinessCar;
import com.zjdiepu.www.model.yw.dto.YwTransfer;
import com.zjdiepu.www.model.yw.response.YwBusinessDetail;
import com.zjdiepu.www.util.ExceptionHelper;

/**      
 * 项目名称：diepu-parent-manage   
 * 类名称：YwShouLiView   
 * 类描述：   
 * 创建人：zhangpp
 * 创建时间：2017年5月31日 上午11:01:59   
 * 修改人：zhangpp
 * 修改时间：2017年5月31日 上午11:01:59   
 * 修改备注：   
 * @version V1.0     
 */
@Controller
@RequestMapping(value= "YwShouLiView", produces="application/json;charset=UTF-8")
@Api(tags = {"作者：张鹏鹏，电话：15158822934"}, produces="application/json;charset=UTF-8")
public class YwShouLiView {

	@Resource
    private ViewScopeControllerHelper viewScopeControllerHelper;
	
	@Resource
    private ICachedDictionaryService cachedDictionaryService;
	
	@Resource
	private IYwBusinessCarService iYwBusinessCarService;
	
	@Resource
	private IYwBusinessCarService ywBusinessCarService;
	
	@Resource
	private YwTransferMapper ywTransferMapper;
	
	
	/**
	* 业务受理/弃贷
	* @author zhangpp
	* @Title: getQiDaiTable 
	* 
	* @param @param model
	* @param @param busiId
	* @param @return    设定文件 
	* @return String    返回类型 
	* @version V1.0
	* @throws
	 */
	@ApiOperation(value = "业务受理/弃贷", response = Boolean.class, httpMethod="GET", tags={"业务受理/弃贷"})
    @RequestMapping(value = "getQiDaiTable", method = RequestMethod.GET)
    public String getQiDaiTable(Model model,String busiId) {
		
		if (StringUtils.isBlank(busiId)) {
			ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
		}
    	model.addAttribute("carCategoryType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_CATEGORY,"请选择..."));
    	model.addAttribute("carColorType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_COLOR,"请选择..."));
    	
    	viewScopeControllerHelper.preparedNowTime(model);
    	YwBusinessDetail ywBusinessDetail = viewScopeControllerHelper.preparedBusiness(busiId, model);
    	YwBusinessCar car = viewScopeControllerHelper.preparedCar(busiId, null,model);
    	if(car != null) {
    		viewScopeControllerHelper.preparedLoan(busiId, car.getId(), model,car.getCarType());
    	}
    	if(ywBusinessDetail != null) {
    		viewScopeControllerHelper.preparedHistoryBusiness(ywBusinessDetail.getCustomerNo(), model);
    	}
    	viewScopeControllerHelper.preparedRegin(model,null,null);
    	viewScopeControllerHelper.preparedCarModel(model);
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
		
		model.addAttribute("busiId", busiId);
		
    	return "ywShouLi/abandonLending";
    }
	
	/**
	* 业务受理 客户过户登记
	* @author zhangpp
	* @Title: ywShouLiKeHuHuoHuDengJi 
	* 
	* @param @param model
	* @param @param busiId
	* @param @return    设定文件 
	* @return String    返回类型 
	* @version V1.0
	* @throws
	 */
	@RequestMapping(value = "ywShouLiKeHuHuoHuDengJi", method = RequestMethod.GET)
	public String ywShouLiKeHuHuoHuDengJi(Model model,String busiId,String statusTransfer) 
	{
		if (StringUtils.isBlank(busiId)) {
			ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
		}
    	model.addAttribute("carCategoryType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_CATEGORY,"请选择..."));
    	model.addAttribute("carColorType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_COLOR,"请选择..."));
    	
    	viewScopeControllerHelper.preparedNowTime(model);
    	YwBusinessDetail ywBusinessDetail = viewScopeControllerHelper.preparedBusiness(busiId, model);
    	YwBusinessCar car = viewScopeControllerHelper.preparedCar(busiId, null,model);
    	if(car != null) {
    		viewScopeControllerHelper.preparedLoan(busiId, car.getId(), model,car.getCarType());
    	}
    	if(ywBusinessDetail != null) {
    		viewScopeControllerHelper.preparedHistoryBusiness(ywBusinessDetail.getCustomerNo(), model);
    	}
    	viewScopeControllerHelper.preparedRegin(model,null,null);
    	viewScopeControllerHelper.preparedCarModel(model);
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
    	
    	//过户信息
    	YwTransfer ywTransfer = new YwTransfer();
    	ywTransfer.setBusiId(busiId);
    	ywTransfer.setDpStatus(1);
    	ywTransfer = ywTransferMapper.selectRefined(ywTransfer);
    	if(null != ywTransfer)
    	{
    		model.addAttribute("ywBusinessCar", ywTransfer);
    	}
    	else
    	{
    		YwBusinessCar ywBusinessCar = new YwBusinessCar();
        	ywBusinessCar.setBusiId(busiId);
        	ywBusinessCar.setDpStatus(1);
        	ywBusinessCar = iYwBusinessCarService.selectRefined(ywBusinessCar);
        	model.addAttribute("ywBusinessCar", ywBusinessCar);
    	}
		
		//判断条件
	 	viewScopeControllerHelper.preparedAttachmentEnum(model);
		model.addAttribute("uuid", UUIDFactory.getUUID());
		model.addAttribute("busiId", busiId);
		model.addAttribute("statusTransfer", statusTransfer);
		
	 	return "ywShouLi/registrationTransfer";
	}
	
	/**
	* 业务受理/按揭日報表
	* @author zhangpp
	* @Title: getBaoBiaoListView 
	* 
	* @param @param model
	* @param @param busiId
	* @param @return    设定文件 
	* @return String    返回类型 
	* @version V1.0
	* @throws
	 */
	@ApiOperation(value = "业务受理/按揭日報表", response = Boolean.class, httpMethod="GET", tags={"业务受理/按揭日報表"})
    @RequestMapping(value = "getBaoBiaoListView", method = RequestMethod.GET)
    public String getBaoBiaoListView(Model model,String busiId,String unitCode,String iden) {
		
		if (StringUtils.isBlank(busiId)) {
			ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
		}
    	model.addAttribute("carCategoryType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_CATEGORY,"请选择..."));
    	model.addAttribute("carColorType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.CAR_COLOR,"请选择..."));
    	
    	viewScopeControllerHelper.preparedNowTime(model);
    	YwBusinessDetail ywBusinessDetail = viewScopeControllerHelper.preparedBusiness(busiId, model);
    	YwBusinessCar car = viewScopeControllerHelper.preparedCar(busiId, null,model);
    	car.setCarTypeDisplay(cachedDictionaryService.getName(car.getCarType(), DataDicType.CAR_TYPE));
    	model.addAttribute("car", car);
    	if(car != null) {
    		viewScopeControllerHelper.preparedLoan(busiId, car.getId(), model,car.getCarType());
    	}
    	if(ywBusinessDetail != null) {
    		viewScopeControllerHelper.preparedHistoryBusiness(ywBusinessDetail.getCustomerNo(), model);
    	}
    	viewScopeControllerHelper.preparedRegin(model,null,null);
    	viewScopeControllerHelper.preparedCarModel(model);
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
		
    	model.addAttribute("iden", iden);
		model.addAttribute("busiId", busiId);
		model.addAttribute("unitCode", unitCode);
		model.addAttribute("uuid", UUIDFactory.getUUID());
		
    	return "ywShouLi/applyLoaningDengji";
    }
}
